//package com.angelababy.canal.listener;
//
//import com.alibaba.otter.canal.protocol.CanalEntry;
//import com.xpand.starter.canal.annotation.CanalEventListener;
//import com.xpand.starter.canal.annotation.ListenPoint;
//import org.springframework.amqp.rabbit.core.RabbitTemplate;
//import org.springframework.beans.factory.annotation.Autowired;
//
//import java.util.Map;
//
//@CanalEventListener
//public class AdListener {
//
//    @Autowired
//    private RabbitTemplate rabbitTemplate;
//
//    @ListenPoint(schema = "changgou_business", table = "tb_ad")
//    public void adUpdate(CanalEntry.EntryType entryType, CanalEntry.RowData rowData) {
//        System.out.println("广告数据发生变化了");
//        Map<String,String> beforeMap=CanalUtil.convertToMap(
//                rowData.getBeforeColumnsList());//修改前数据
//        rowData.getBeforeColumnsList().forEach((c) -> System.out.println("更新前的数据：" + c.getName() + "==" + c.getValue()));
//        Map<String,String>afterMap=CanalUtil.convertToMap(
//                rowData.getAfterColumnsList());//修改后数据
//                rowData.getAfterColumnsList().forEach((c) -> System.out.println("更新后的数据：" + c.getName() + "==" + c.getValue()));
//
//
//        String beforePosition = beforeMap.get("position");
//        if (beforePosition != null) {
//            System.out.println("beforePosition发送消息到mq");
//            rabbitTemplate.convertAndSend("", "ad_update_queue"
//                    , beforePosition);
//        }
//        String afterPosition = afterMap.get("position");
//        if (afterPosition != null && !afterPosition.equals(beforePosition)
//        ) {
//            System.out.println("afterPosition发送消息到mq");
//            rabbitTemplate.convertAndSend("", "ad_update_queue"
//                    , afterPosition);
//        }
//    }
//
//}
